Ext.define("App.projectorder.view.ProjectOrderFormPanel", {
    extend: 'Ext.form.Panel',
    alias: 'widget.ProjectOrderFormPanel',
    requires: ['App.project.field.ProjectTypeComboBox', 'App.project.field.SiteComboBox'],
    padding: 5,
    node: null,
    title: 'PO信息',
    layout: 'border',
    items: [{
        xtype: 'InnerProjectOrderInfo',
        region: 'north',
        height: 125
    }, {
        xtype: 'InnerProjectList',
        columnWidth: 1,
        name: 'children',
        region: 'center',
        listeners: {
            rowdblclick: function ($this, record) {
                this.up('ProjectOrderReport').fireEvent('ondblclickproject', $this, record)
            },
            cellclick: function ($this, td, cellIndex, record, tr, rowIndex, e, eOpts) {
                if (cellIndex == 2) {
                    this.up('ProjectOrderReport').fireEvent('ondblclickproject', $this, record)
                }
            }
        }
    }],
    initComponent: function () {
        var me = this;
        this.loader = {
            loadMask: '加载...',
            loadOnRender: true,
            autoLoad: true,
            url: 'projectorder/get_with_project_by_id',
            params: {id: me.up('ProjectOrderReport').node.data.id},
            renderer: function (loader, response, active) {
                var result = response.result;
                if (result.success == true) {
                    me.loadRecord(Ext.create('App.projectorder.model.ProjectOrderModel', response.result.data));
                }
                return true;
            }
        }
        this.callParent(arguments);
    }
})
Ext.define('App.projectorder.view.InnerProjectOrderInfo', {
    extend: 'Ext.panel.Panel',
    alias: ['widget.InnerProjectOrderInfo'],
    layout: 'column',
    defaults: {
        labelWidth: 120,
        columnWidth: .25,
        readOnly: true,
        labelAlign: 'right',
        margin: '5 5 5 5',
        height: 32,
        labelStyle: "padding-top:8px;",
        fieldStyle: "padding:0px 6px 2px"
    },
    items: [{
        xtype: 'textfield',
        fieldLabel: 'PR/PO号',
        name: 'po',
        readOnly: true
    }, {
        xtype: 'textfield',
        fieldLabel: 'PO名称',
        name: 'name',
        readOnly: true
    }, {
        xtype: 'textfield',
        fieldLabel: '在岸/离岸',
        name: 'onSite',
        readOnly: true
    }, {
        xtype: 'textfield',
        fieldLabel: '内部PO号',
        name: 'innerPo',
        readOnly: true
    }, {
        xtype: 'textfield',
        fieldLabel: '交付部',
        name: 'deliveryDepartment',
        readOnly: true
    }, {
        xtype: 'textfield',
        fieldLabel: '合同类型',
        name: 'contractType',
        readOnly: true
    }, {
        xtype: 'textfield',
        fieldLabel: '服务目录',
        name: 'serviceDirectory',
        readOnly: true
    }, {
        xtype: 'textfield',
        fieldLabel: '实施地域',
        name: 'effectArea',
        readOnly: true
    }, {
        xtype: 'textfield',
        fieldLabel: '交付部经理',
        name: 'deliveryManager',
        readOnly: true
    }, {
        xtype: 'textfield',
        fieldLabel: '华为合作代表',
        name: 'huaweiRepresentative',
        readOnly: true
    }, {
        xtype: 'textfield',
        fieldLabel: '预计总工作量(人天)',
        name: 'planTotalQuantity',
        readOnly: true
    }, {
        xtype: 'datefield',
        fieldLabel: '客户立项时间',
        name: 'startDate',
        format: 'Y-m-d',
        readOnly: true
    }]
});
Ext.define('App.projectorder.view.InnerProjectList', {
    extend: 'Extend.form.field.GridField',
    alias: ['widget.InnerProjectList'],
    userCls: 'high-line30',
    tbar: ['->'],
    selModel: {selType: 'rowmodel', mode: 'SINGLE'},
    forceFit: true,
    emptyText: '此PO下没有任务项目',
    sortableColumns: false,
    columns: [{
        header: 'ID',
        dataIndex: 'id',
        hidden: true
    }, {
        header: '项目编码',
        dataIndex: 'projectCode',
        width: 180,
        menuDisabled: true, height: 35
    }, {
        header: '项目名称',
        dataIndex: 'name',
        width: 320,
        menuDisabled: true, renderer: function (v, m, r) {
            return '<span style="cursor: pointer;color: royalblue;">' + v + '</span>';
        }
    }, {
        header: '项目经理',
        dataIndex: 'projectManager',
        menuDisabled: true,
        width: 120
    }, {
        header: '范围',
        dataIndex: 'xx',
        menuDisabled: true,
        width: 120
    }, {
        header: '进度',
        dataIndex: 'xx',
        menuDisabled: true
    }, {
        header: '质量',
        dataIndex: 'xx',
        width: 120,
        menuDisabled: true
    }, {
        header: '效率',
        dataIndex: 'xx',
        width: 120,
        menuDisabled: true
    }, {
        header: 'PO占比',
        dataIndex: 'poProportion',
        menuDisabled: true,
        formatter: 'percent("###.##")'
    }, {
        header: '预计工作量(人天)',
        dataIndex: 'projectWorkload',
        width: 160,
        menuDisabled: true
    }, {
        xtype: 'ymdcolumn',
        header: '启动日期',
        dataIndex: 'startDate',
        menuDisabled: true
    }, {
        xtype: 'ymdcolumn',
        header: '结束日期',
        dataIndex: 'plannedEndDate',
        menuDisabled: true
    }]
})


